{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "我吃了二两小米粥增加了45kcal\n",
      "\n",
      "我吃了二两粗粮馒头增加了223kcal\n",
      "\n",
      "我吃了二两全麦面包增加了235kcal\n",
      "\n",
      "我吃了二两瘦猪肉增加了143kcal\n",
      "\n",
      "我吃了二两鸡翅增加了194kcal\n",
      "\n",
      "我吃了二两培根增加了181kcal\n",
      "\n",
      "我吃了二两火腿肠增加了212kcal\n"
     ]
    }
   ],
   "source": [
    "foods_calories={}\n",
    "foods_calories['小米粥']='45kcal'\n",
    "foods_calories['粗粮馒头']='223kcal'\n",
    "foods_calories['全麦面包']='235kcal'\n",
    "foods_calories['瘦猪肉']='143kcal'\n",
    "foods_calories['鸡翅']='194kcal'\n",
    "foods_calories['培根']='181kcal'\n",
    "foods_calories['火腿肠']='212kcal'\n",
    "\n",
    "for food,calories in foods_calories.items():\n",
    "    print(\"\\n我吃了二两%s\"%food+\"增加了%s\"%calories)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "(一小时4公里)255卡\n",
      "\n",
      "What sport do you think this is?\n",
      "慢走  跑步  羽毛球  \n"
     ]
    }
   ],
   "source": [
    "sports_calories = {'慢走': '(一小时4公里)255卡',\n",
    "                '跑步': '(一小时9公里)655卡',\n",
    "                '羽毛球': '(一小时)440卡',\n",
    "                }\n",
    "\n",
    "def show_words(sports_calories):\n",
    "    # A simple function to show the words in the dictionary.\n",
    "    display_message = \"\"\n",
    "    for calories in sports_calories.keys():\n",
    "        display_message += calories + '  '\n",
    "    print(display_message)\n",
    "\n",
    "# Print each meaning, one at a time, and ask the user\n",
    "#  what word they think it is.\n",
    "for sports in sports_calories.values():\n",
    "    print(\"\\n%s\" % sports)\n",
    "\n",
    "    # Assume the guess is not correct; keep guessing until correct.\n",
    "    correct = False\n",
    "    while not correct:\n",
    "        \n",
    "        print(\"\\nWhat sport do you think this is?\")\n",
    "        show_words(sports_calories)\n",
    "        guessed_word = input(\"- \")    \n",
    "        \n",
    "        # The guess is correct if the guessed word's meaning matches the current meaning.\n",
    "        if sports_calories[guessed_word] == sports:\n",
    "            print(\"You got it!\")\n",
    "            correct = True\n",
    "        else:\n",
    "            print(\"Sorry, that's just not the right word.\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "九岭头1794米\n",
      "五虎岗1891米\n",
      "军峰山1760米\n",
      "南风面2120米\n",
      "独竖尖2128米\n",
      "玉京峰1819米\n",
      "白鹤峰1918米\n",
      "过风坳1887米\n",
      "黄冈山2157米\n",
      "齐云山2061米\n"
     ]
    }
   ],
   "source": [
    "mountains_altitude = {'独竖尖':'2128米',\n",
    "                     '南风面':'2120米',\n",
    "                     '齐云山':'2061米',\n",
    "                     '白鹤峰':'1918米',\n",
    "                     '五虎岗':'1891米',\n",
    "                     '过风坳':'1887米',\n",
    "                     '玉京峰':'1819米',\n",
    "                     '黄冈山':'2157米',\n",
    "                     '军峰山':'1760米',\n",
    "                     '九岭头':'1794米',\n",
    "                     \n",
    "}\n",
    "for mountain in sorted(mountains_altitude.keys()):\n",
    "    print(\"%s%s\"%(mountain.title(),mountains_altitude[mountain]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "我知道的李晖\n",
      "身高:170\n",
      "爱好: 足球\n",
      "技能: 足球\n",
      "\n",
      "我知道的陶仁杰\n",
      "身高:170\n",
      "爱好: 学习\n",
      "技能: 认真勤奋\n",
      "\n",
      "我知道的张桐源\n",
      "身高:170\n",
      "爱好: 学习\n",
      "技能: 都很简单\n"
     ]
    }
   ],
   "source": [
    "roommates_information = {'李晖':{'身高': '170', '爱好': '足球', '技能':'足球'},\n",
    "        '陶仁杰':{'身高': '170', '爱好': '学习', '技能':'认真勤奋'},\n",
    "        '张桐源':{'身高': '170', '爱好': '学习', '技能':'都很简单'},\n",
    "        }\n",
    "for name, information in roommates_information.items():\n",
    "    print(\"\\n我知道的%s\" %name)\n",
    "    print(\"身高:\" + information['身高'])\n",
    "    print(\"爱好: \" + information['爱好'])\n",
    "    print(\"技能: \" + information['技能'])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
